package com.github.cakin.shiro.chapter14.entity;

import java.io.Serializable;

import static com.github.cakin.shiro.chapter14.constant.Constant.NUM31;

/**
 * @className: UserRole
 * @description: 用户角色关系
 * @date: 2020/5/19
 * @author: cakin
 */
public class UserRole implements Serializable {
    /**
     * 用户Id
     */
    private Long userId;
    /**
     * 角色Id
     */
    private Long roleId;

    public Long getUserId() {
        return userId;
    }

    public void setUserId( Long userId ) {
        this.userId = userId;
    }

    public Long getRoleId() {
        return roleId;
    }

    public void setRoleId( Long roleId ) {
        this.roleId = roleId;
    }

    @Override
    public boolean equals( Object o ) {
        if (this == o) {
            return true;
        }
        if (o == null || getClass() != o.getClass()) {
            return false;
        }

        UserRole userRole = (UserRole) o;

        if (roleId != null ? !roleId.equals(userRole.roleId) : userRole.roleId != null) {
            return false;
        }
        if (userId != null ? !userId.equals(userRole.userId) : userRole.userId != null) {
            return false;
        }

        return true;
    }

    @Override
    public int hashCode() {
        int result = userId != null ? userId.hashCode() : 0;
        result = NUM31 * result + (roleId != null ? roleId.hashCode() : 0);
        return result;
    }

    @Override
    public String toString() {
        return "UserRole{"
                + "userId=" + userId
                + ", roleId=" + roleId
                + '}';
    }
}
